package com.fcg.multiproject01.webmodule.filter;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.filter.OncePerRequestFilter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;

/**
 * @author FCG
 */
@Slf4j
public class CommonFilter extends OncePerRequestFilter {
    @Override
    protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException {
        Enumeration<String> hns = httpServletRequest.getHeaderNames();
        while (hns.hasMoreElements()) {
            String hn = hns.nextElement();
            String val = httpServletRequest.getHeader(hn);
            log.info("header pairs: {} = {}", hn, val);
        }
        String val = httpServletRequest.getHeader("host");
        log.info("host = {}", val);
        filterChain.doFilter(httpServletRequest, httpServletResponse);
    }
}






















